<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">匹配规则管理</ui:define>
    <ui:define name="content">
        <h:form>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton value="编辑" icon="fa fa-edit"
                                         actionListener="#{matchRuleInfoBean.changeStatusToEdit}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{matchRuleInfoBean.isView() and security:areAllGranted('LOAN_FAMILY_TAGS_FIRST_PARTY_EDIT')}"/>
                        <p:commandButton value="保存" icon="fa fa-save"
                                         actionListener="#{matchRuleInfoBean.onSave}"
                                         rendered="#{matchRuleInfoBean.isNotView() and security:areAnyGranted('LOAN_FAMILY_TAGS_FIRST_PARTY_EDIT,LOAN_FAMILY_TAGS_FIRST_PARTY_ADD')}"
                                         update="@form"/>
                        <p:commandButton value="取消" icon="fa fa-reply"
                                         actionListener="#{matchRuleInfoBean.changeStatusToView}"
                                         rendered="#{matchRuleInfoBean.isEdit()}"
                                         process="@this"
                                         update="@form"/>
                        <p:button value="返回" icon="fa fa-reply-all" href="#{currentUserBean.back}"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12">
                    <div class="card">
                        <div class="ui-g">
                            <div class="ui-g-12"><h3><b>推荐位-广告位配置</b></h3></div>
                            <div class="ui-g-2">
                                <p:outputLabel for="recommendPosition" value="推荐位"/>
                            </div>
                            <div class="ui-g-4">
                                <p:selectOneMenu id="recommendPosition"
                                                 value="#{matchRuleInfoBean.$.recommendPosition}" filter="true"
                                                 filterMatchMode="contains"
                                                 disabled="#{matchRuleInfoBean.isNotAdd()}">
                                    <p:ajax event="change" update="@form"/>
                                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                  noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{matchRuleInfoBean.dictionaries[DictionaryCode.RECOMMEND_POSITION]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>
                            </div>
                            <div class="ui-g-2">
                                <p:outputLabel for="adverPosition" value="广告位"/>
                            </div>
                            <div class="ui-g-4">
                                <p:selectOneMenu id="adverPosition"
                                                 value="#{matchRuleInfoBean.$.advertPosition}" filter="true"
                                                 filterMatchMode="contains"
                                                 disabled="#{matchRuleInfoBean.isNotAdd()}">
                                    <p:ajax event="change" update="@form"/>
                                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                  noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{matchRuleInfoBean.dictionaries[DictionaryCode.ADVERT_POSITION]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>
                            </div>
                        </div>
                    </div>
                </div>
                <h:panelGroup
                        rendered="#{matchRuleInfoBean.$.advertPosition !=null and matchRuleInfoBean.$.recommendPosition!=null}">
                    <div class="ui-g-4">
                        <div class="card">
                            <h3><b>匹配规则配置</b></h3>
                            <div class="ui-g">
                                <div class="ui-g-4 loan-title">配置</div>
                                <div class="ui-g-8 loan-title">配置项</div>
                                <div class="ui-g-4" style="text-align: center">信息流渠道</div>
                                <div class="ui-g-8" style="text-align: center">
                                    <p:selectManyMenu value="#{matchRuleInfoBean.$.config.infoFlowChannels}"
                                                      filter="true"
                                                      filterMatchMode="contains" showCheckbox="true"
                                                      disabled="#{matchRuleInfoBean.isView()}">
                                        <f:selectItems value="#{matchRuleInfoBean.infoFlowChannels}" var="channel"
                                                       itemLabel="#{channel.channelName}"
                                                       itemValue="#{channel.channelCode}"/>
                                    </p:selectManyMenu>
                                </div>
                                <div class="ui-g-4" style="text-align: center">同行渠道</div>
                                <div class="ui-g-8" style="text-align: center">
                                    <p:selectManyMenu value="#{matchRuleInfoBean.$.config.industryChannels}"
                                                      filter="true"
                                                      filterMatchMode="contains" showCheckbox="true"
                                                      disabled="#{matchRuleInfoBean.isView()}">
                                        <f:selectItems value="#{matchRuleInfoBean.industryChannels}" var="channel"
                                                       itemLabel="#{channel.channelName}"
                                                       itemValue="#{channel.channelCode}"/>
                                    </p:selectManyMenu>
                                </div>
                                <div class="ui-g-4" style="text-align: center">应用分发渠道</div>
                                <div class="ui-g-8" style="text-align: center">
                                    <p:selectManyMenu
                                            value="#{matchRuleInfoBean.$.config.applicationDistributionChannels}"
                                            filter="true"
                                            filterMatchMode="contains" showCheckbox="true"
                                            disabled="#{matchRuleInfoBean.isView()}">
                                        <f:selectItems value="#{matchRuleInfoBean.applicationDistributionChannels}"
                                                       var="channel"
                                                       itemLabel="#{channel.channelName}"
                                                       itemValue="#{channel.channelCode}"/>
                                    </p:selectManyMenu>
                                </div>
                                <div class="ui-g-4" style="text-align: center">短信渠道</div>
                                <div class="ui-g-8" style="text-align: center">
                                    <p:selectManyMenu value="#{matchRuleInfoBean.$.config.smsChannels}" filter="true"
                                                      filterMatchMode="contains" showCheckbox="true"
                                                      disabled="#{matchRuleInfoBean.isView()}">
                                        <f:selectItems value="#{matchRuleInfoBean.smsChannels}" var="channel"
                                                       itemLabel="#{channel.channelName}"
                                                       itemValue="#{channel.channelCode}"/>
                                    </p:selectManyMenu>
                                </div>
                                <div class="ui-g-4" style="text-align: center">其他渠道</div>
                                <div class="ui-g-8" style="text-align: center">
                                    <p:selectManyMenu value="#{matchRuleInfoBean.$.config.otherChannels}" filter="true"
                                                      filterMatchMode="contains" showCheckbox="true"
                                                      disabled="#{matchRuleInfoBean.isView()}">
                                        <f:selectItems value="#{matchRuleInfoBean.otherChannels}" var="channel"
                                                       itemLabel="#{channel.channelName}"
                                                       itemValue="#{channel.channelCode}"/>
                                    </p:selectManyMenu>
                                </div>
                                <div class="ui-g-4" style="text-align: center">产品</div>
                                <div class="ui-g-8" style="text-align: center">
                                    <p:selectManyMenu value="#{matchRuleInfoBean.$.config.products}" filter="true"
                                                      filterMatchMode="contains" showCheckbox="true"
                                                      disabled="#{matchRuleInfoBean.isView()}">
                                        <f:selectItems value="#{matchRuleInfoBean.commProductIds}" var="product"
                                                       itemValue="#{product.productId}"
                                                       itemLabel="#{product.name}"/>
                                    </p:selectManyMenu>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="ui-g-4">
                        <div class="card">
                            <h3><b>甲方准入门槛</b></h3>
                            <div class="ui-g">
                                <div class="ui-g-6 loan-title">准入门槛</div>
                                <div class="ui-g-6 loan-title">是否启用</div>
                                <div class="ui-g-6" style="text-align: center">用户身份标签</div>
                                <div class="ui-g-6" style="text-align: center"><p:inputSwitch
                                        value="#{matchRuleInfoBean.$.item.identityTag}"
                                        disabled="#{matchRuleInfoBean.isView()}" offLabel="否" onLabel="是"/>
                                </div>
                                <div class="ui-g-6" style="text-align: center">用户最小年龄</div>
                                <div class="ui-g-6" style="text-align: center"><p:inputSwitch
                                        value="#{matchRuleInfoBean.$.item.minAge}"
                                        disabled="#{matchRuleInfoBean.isView()}"
                                        offLabel="否" onLabel="是"/>
                                </div>
                                <div class="ui-g-6" style="text-align: center">用户最大年龄</div>
                                <div class="ui-g-6" style="text-align: center"><p:inputSwitch
                                        value="#{matchRuleInfoBean.$.item.maxAge}"
                                        disabled="#{matchRuleInfoBean.isView()}"
                                        offLabel="否" onLabel="是"/>
                                </div>
                                <div class="ui-g-6" style="text-align: center">芝麻分值</div>
                                <div class="ui-g-6" style="text-align: center"><p:inputSwitch
                                        value="#{matchRuleInfoBean.$.item.sesamePoint}"
                                        disabled="#{matchRuleInfoBean.isView()}" offLabel="否" onLabel="是"/>
                                </div>
                                <div class="ui-g-6" style="text-align: center">手机最低入网时长</div>
                                <div class="ui-g-6" style="text-align: center"><p:inputSwitch
                                        value="#{matchRuleInfoBean.$.item.phoneOnlineTime}"
                                        disabled="#{matchRuleInfoBean.isView()}" offLabel="否" onLabel="是"/>
                                </div>
                                <div class="ui-g-6" style="text-align: center">是否有信用卡</div>
                                <div class="ui-g-6" style="text-align: center"><p:inputSwitch
                                        value="#{matchRuleInfoBean.$.item.hasCreditCard}"
                                        disabled="#{matchRuleInfoBean.isView()}" offLabel="否" onLabel="是"/>
                                </div>
                                <div class="ui-g-6" style="text-align: center">地区限制</div>
                                <div class="ui-g-6" style="text-align: center"><p:inputSwitch
                                        value="#{matchRuleInfoBean.$.item.areaLimit}"
                                        disabled="#{matchRuleInfoBean.isView()}"
                                        offLabel="否" onLabel="是"/>
                                </div>
                                <div class="ui-g-6" style="text-align: center">API是否在限期内已投递</div>
                                <div class="ui-g-6" style="text-align: center"><p:inputSwitch
                                        value="#{matchRuleInfoBean.$.item.apiDeliveryLimit}"
                                        disabled="#{matchRuleInfoBean.isView()}"
                                        offLabel="否" onLabel="是"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="ui-g-4">
                        <div class="card">
                            <h3><b>匹配优先级</b></h3>
                            <div class="ui-g">
                                <div class="ui-g-6 loan-title">准入门槛</div>
                                <div class="ui-g-6 loan-title">优先级</div>
                                <div class="ui-g-6" style="text-align: center">金额匹配度</div>
                                <div class="ui-g-6" style="text-align: center"><p:spinner
                                        value="#{matchRuleInfoBean.$.priority.amount}"
                                        disabled="#{matchRuleInfoBean.isView()}"/></div>

                                <div class="ui-g-6" style="text-align: center">上线时间(月)</div>
                                <div class="ui-g-6" style="text-align: center"><p:spinner
                                        value="#{matchRuleInfoBean.$.priority.onlineTime}"
                                        disabled="#{matchRuleInfoBean.isView()}"/></div>

                                <div class="ui-g-6" style="text-align: center">所需资料项</div>
                                <div class="ui-g-6" style="text-align: center"><p:spinner
                                        value="#{matchRuleInfoBean.$.priority.necessaryData}"
                                        disabled="#{matchRuleInfoBean.isView()}"/></div>

                                <div class="ui-g-6" style="text-align: center">审批通过率</div>
                                <div class="ui-g-6" style="text-align: center"><p:spinner
                                        value="#{matchRuleInfoBean.$.priority.approvalRate}"
                                        disabled="#{matchRuleInfoBean.isView()}"/></div>
                            </div>
                        </div>
                    </div>
                </h:panelGroup>
            </div>
        </h:form>
    </ui:define>
</ui:composition>